// 内容模块类型定义

// 内容类型枚举
export enum ContentType {
  IMAGE = 'IMAGE',
  VIDEO = 'VIDEO'
}

// 上传状态枚举
export enum UploadStatus {
  PENDING = 'PENDING',
  UPLOADING = 'UPLOADING',
  UPDATING = 'UPDATING',
  COMPLETED = 'COMPLETED',
  FAILED = 'FAILED'
}

// 操作类型枚举
export enum OperationType {
  UPLOAD_IMAGES = 'UPLOAD_IMAGES',
  UPLOAD_VIDEO = 'UPLOAD_VIDEO',
  UPLOAD_COVER = 'UPLOAD_COVER',
  UPDATE_IMAGES = 'UPDATE_IMAGES',
  UPDATE_VIDEO = 'UPDATE_VIDEO',
  UPDATE_COVER = 'UPDATE_COVER'
}

// 操作状态枚举
export enum OperationStatus {
  PENDING = 'PENDING',
  IN_PROGRESS = 'IN_PROGRESS',
  COMPLETED = 'COMPLETED',
  FAILED = 'FAILED'
}

// 排序方式枚举
export enum OrderBy {
  CREATED_AT = 'created_at',
  LIKE_COUNT = 'like_count'
}

// 图片信息
export interface ContentImage {
  id: number;
  imageUrl: string;
  createdAt: string;
}

// 视频信息
export interface ContentVideo {
  id: number;
  videoUrl: string;
  createdAt: string;
}

// 基础内容信息
export interface Content {
  id: number;
  userId: number;
  contentType: ContentType;
  title: string;
  textContent: string;
  coverUrl: string;
  uploadStatus: UploadStatus;
  imageUrls: string[];
  videoUrls: string[];
  images?: ContentImage[]; // 完整的图片信息（可选，用于编辑）
  videos?: ContentVideo[]; // 完整的视频信息（可选，用于编辑）
  likeCount: number;
  commentCount: number;
  viewCount: number;
  isPublished: boolean;
  isLiked: boolean;
  createdAt: string;
  updatedAt: string;
}

// 内容列表项
export interface ContentListItem {
  id: number;
  userId: number;
  contentType: ContentType;
  title: string;
  isPublished: boolean;
  uploadStatus: UploadStatus;
  coverUrl: string;
  imageUrls: string[]; // 添加图片URL数组，用于轮播显示
  likeCount: number;
  commentCount: number;
  viewCount: number;
  isLiked: boolean;
  createdAt: string;
  updatedAt: string;
}

// 内容详情
export interface ContentDetail {
  id: number;
  userId: number;
  username: string;
  userAvatar: string;
  contentType: ContentType;
  title: string;
  textContent: string;
  coverUrl: string;
  likeCount: number;
  commentCount: number;
  viewCount: number;
  isPublished: boolean;
  isLiked: boolean;
  createdAt: string;
  updatedAt: string;
  images: ContentImage[];
  videos: ContentVideo[];
}

// 媒体文件信息
export interface ContentMedia {
  contentId: number;
  contentType: ContentType;
  coverUrl: string;
  images: ContentImage[];
  videos: ContentVideo[];
}

// 操作日志
export interface OperationLog {
  id: number;
  contentId: number;
  operationType: OperationType;
  operationStatus: OperationStatus;
  totalOperations: number;
  completedOperations: number;
  failedOperations: number | null;
  errorMessage: string | null;
  startedAt: string;
  completedAt: string | null;
  createdBy: number;
}

// 分页响应基础类型
export interface PaginatedResponse<T> {
  total: number;
  totalPages: number;
  pageNum: number;
  pageSize: number;
  data: T[];
}

// 内容列表响应
export interface ContentListResponse extends PaginatedResponse<ContentListItem> {
  contents: ContentListItem[];
}

// 操作日志列表响应
export interface OperationLogListResponse extends PaginatedResponse<OperationLog> {
  logs: OperationLog[];
}

// 创建内容请求
export interface CreateContentRequest {
  contentType: ContentType;
  title: string;
  textContent: string;
  cover?: File;
  images?: File[];
  video?: File;
}

// 更新内容文本请求
export interface UpdateContentTextRequest {
  title: string;
  textContent: string;
}

// 更新封面请求
export interface UpdateCoverRequest {
  cover: File;
}

// 更新视频请求
export interface UpdateVideoRequest {
  video: File;
}

// 批量更新图片请求
export interface UpdateImagesRequest {
  deleteImageIds?: string; // 逗号分隔的ID列表
  newImages?: File[];
}

// 内容查询参数
export interface ContentQueryParams {
  page?: number;
  size?: number;
  title?: string;
  textContent?: string;
  contentType?: string; // 'IMAGE' | 'VIDEO' | 'all'
  orderBy?: OrderBy;
  userId?: number;
}

// 操作日志查询参数
export interface OperationLogQueryParams {
  page?: number;
  size?: number;
  operationType?: string; // OperationType | 'all'
  contentId?: number;
  userId?: number;
}

// 内容操作日志
export interface ContentOperationLog {
  id: number;
  contentId: number;
  operationType: OperationType;
  operationStatus: OperationStatus;
  totalOperations: number;
  completedOperations: number;
  failedOperations: number | null;
  errorMessage: string | null;
  startedAt: string;
  completedAt: string | null;
  createdBy: number;
}

// 内容操作日志查询参数
export interface ContentOperationLogQueryParams {
  page?: number;
  size?: number;
  operationType?: string; // OperationType | 'all'
  contentId?: number;
  userId?: number;
}

// 内容操作日志列表响应
export interface ContentOperationLogListResponse {
  total: number;
  totalPages: number;
  pageNum: number;
  pageSize: number;
  logs: ContentOperationLog[];
}

// 注意：ApiResponse 类型已在 auth.ts 中定义，这里不重复定义 